<!DOCTYPE html>
<html>
<#include "../../common/header.ftl">
<script src="${basePath}/js/goods/list.js?v=201711021700"></script>
<head>
<meta charset="UTF-8">
<title>商品管理</title>
<style>
	.left{
		float:left;
		min-width:100px;
		margin-left: 10px;
	}
	.red_text{
		color:red;
	}
	.blue_text{
		color:blue;
	}
	.table-margin{
		margin:5px 3%;
		width:92%;
	}
	/*.dropdown-menu li{
		height:40px;
		margin:0px 5px;
	}
	.dropdown-menu a{
		height:30px;
		font-size: 18px;
	}*/
</style>

</head>
<body>
   
<div class="container" style="margin-left:5%;width:92%;">
<form class="layui-form left" action="#" >
<div class="layui-form-item ">
    <label class="layui-form-label left" >商品品牌</label>
	<div class="layui-input-block left">
      <select name="goodsBrand">
        <option value="" >所有</option>
        <option value="" >所有</option>
        <#list page.brandItemList! as brands>
        <option value="${brands.id!}" <#if param.brandId?? && param.brandId==brands.id> selected</#if> >${brands.name!}</option>
        </#list>
      </select>
    </div>
    <label class="layui-form-label left" >商品品类</label>
	<div class="layui-input-block left">
      <select name="goodsCategory">
        <option value="" >所有</option>
        <option value="" >所有</option>
        <#list page.categoryItemList! as category>
	        <option value="${category.categoryId!}" <#if param.categoryId?? && param.categoryId==category.categoryId> selected</#if>>${category.categoryName!}</option>
	        <#list category.secondChildList! as secondCategory>
		   		 <option value="${secondCategory.categoryId!}" <#if param.categoryId?? && param.categoryId==secondCategory.categoryId> selected</#if>>--${secondCategory.categoryName!}</option>
		   		 <#list secondCategory.thirdChildList! as thirdCategory>
		   		 	<option value="${thirdCategory.categoryId!}" <#if param.categoryId?? && param.categoryId==thirdCategory.categoryId> selected</#if>>----${thirdCategory.categoryName!}</option>
		   		 	<#list thirdCategory.fourChildList! as fourCategory>
		   		 		<option value="${fourCategory.id!}" <#if param.categoryId?? && param.categoryId==fourCategory.id> selected</#if>>------${fourCategory.name!}</option>
		   		 	</#list>
		   		 </#list>
	        </#list>
       </#list>
      </select>
    </div>
    
    <label class="layui-form-label left" >商品状态</label>
	<div class="layui-input-block left">
	      <select name="goodsStatus">
	        <option value="" >所有</option>
	        <option value="" >所有</option>
	        <option value="sale" <#if param.state?? && param.state=="sale"> selected</#if>>在售</option>
	        <option value="wait" <#if param.state?? && param.state=="wait"> selected</#if>>待售中</option>
	        <option value="down" <#if param.state?? && param.state=="down"> selected</#if>>已下架</option>
	        <option value="push" <#if param.state?? && param.state=="push"> selected</#if>>推送的商品，待处理</option>
	      </select>
	</div>
</div>
<div class="layui-form-item ">	
    <label class="layui-form-label left" >是否推荐</label>
	<div class="layui-input-block left">
      <select name="goodsisSp">
        <option value="" >所有</option>
        <option value="" >所有</option>
        <option value="0" <#if param.isSp?? && param.isSp==0> selected</#if>>否</option>
        <option value="1" <#if param.isSp?? && param.isSp==1> selected</#if>>是</option>
      </select>
    </div>
    
	<label class="layui-form-label left">创建时间</label>
    <div class="layui-input-inline left">
      <input class="layui-input" placeholder="开始" id="LAY_demorange_s"  name="timeStart" value="${param.timeStart!}">
    </div>
    <div class="layui-form-mid">-</div>
    <div class="layui-input-inline left">
      <input class="layui-input " placeholder="截止" id="LAY_demorange_e"  name="timeEnd" value="${param.timeEnd!}">
    </div>
</div>
<div class="layui-form-item">
 <div class="layui-input-block left">
      <input type="text" name="keyword" value="${param.keyword!}"   placeholder="商品名称/款号" autocomplete="off" 
      class="layui-input" style="width:400px;margin-right:200px;margin-left:30px">
    </div>
     <div class="layui-input-block left">
      <button type="button" class="layui-btn"  id="search-button">搜索</button>
      <#if permission?? && (permission.P1103??)>
      <button type="button" class="layui-btn" id="add-button">添加商品信息</button>
      </#if>
    </div>
</div>
</form>
</div>

    <table class="table table-margin">
  <thead>
      <tr>
         <th>商品名称</th>
         <th>款式编码</th>
         <th>商品类型</th>
         <th>商品图片</th>
         <th>商品价格</th>
         <th>商品状态</th>
         <th>季度</th>
         <th>是否推荐</th>
         <th>发布人</th>
         <th>发布时间</th>
         <th>操作</th>
      </tr>
   </thead>
	<tbody>
	<#list page.goodsItemList! as goods>
			<tr>
				<td>${goods.goodsName!}</td>
				<td>${goods.styleCode!}</td>
				<td>${goods.typeName!}</td>
				<td>
				<#if goods.coverImage??>
			 		<img data-img="${goods.coverImage!}" class ="one-image" src="${imgUrl+goods.coverImage}" height="50px" width="50px">
			 	<#else>
			 		<img data-img="" class ="one-image" src="${basePath}/images/default_goods.png" height="50px" width="50px" >
			 	</#if>
			 	</td>
				<td>${goods.price?string('#0.00')}</td>
				<td><#if goods.goodsStatus == "sale">在售
					<#elseif goods.goodsStatus == "wait">待售中
					<#elseif goods.goodsStatus == "down"><span class="blue_text">已下架</span>
					<#elseif goods.goodsStatus == "push"><span class="red_text">待处理</span>
					<#else><span class="red_text">已删除</span>
					</#if>
				</td>
				<td><#if goods.quarter ==1>春季<#elseif goods.quarter==2>夏季<#elseif goods.quarter==3>秋季<#elseif goods.quarter==4>冬季</#if></td>
				<td><#if goods.isSp==1>是<#else>否</#if></td>
				<td>${goods.pubuser!}</td>
				<#if goods.pubdate ??>
				   <td>${goods.pubdate?string("yyyy-MM-dd HH:mm:ss")!}</td>
				<#else>
					<td></td>
				</#if>
				<td>
				<div class="btn-group ">
				  <button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
				    	操作<span class="caret"></span>
				  </button>
				  <ul class="dropdown-menu">
				  <#if permission?? && (permission.P1104??)>
				    <li><a href="javascript:void(0);" onclick="openEdit('${goods.id!}')">修改</a></li>
				  </#if>
				  <#if permission?? && (permission.P1106??)>
				    <#if goods.goodsStatus == "sale">
				   		<li><a href="javascript:void(0);" onclick="updateStatus('${goods.id!}','down')")">下架</a></li>
				    <#elseif goods.goodsStatus == "down" || goods.goodsStatus == "wait">
				    	<li><a href="javascript:void(0);" onclick="updateStatus('${goods.id!}','sale')")">上架</a></li>
				    </#if>
				    <li><a href="javascript:void(0);" onclick="updateStatus('${goods.id!}','delete')">删除</a></li>
				  </#if>
				  </ul>
				</div>
				</td>
			</tr>
	</#list>
	</tbody>
	</table>
 
	<#-- 翻页模块代码 -->
	<ul class="pager">
		<li><a href="javascript:void(0);" onclick="fanye('1')">首页</a></li>
		<#if page.pageNo!=1 > 
		<li><a	href="javascript:void(0);" onclick="fanye('${page.prevPage}')">上一页</a></li>
		<#else>
		<li><a href="javascript:void(0);">上一页</a></li> 
		</#if>
		<li><a href="javascript:void(0);">第${page.pageNo}页/共${page.totalPage}页</a></li>
		<#if (page.nextPage>page.pageNo) >
		<li><a href="javascript:void(0);" onclick="fanye('${page.nextPage}')">下一页</a></li>
		<#else>
		<li><a href="javascript:void(0);">下一页</a></li>
		</#if>
		<li><a href="javascript:void(0);" onclick="fanye('${page.totalPage}')">尾页</a></li>
	</ul>
</body>
<script type="text/javascript">
	var basePath="${basePath}";
	var H5GoodsUrl="${H5GoodsUrl!}";
	var init={
		brandId:"${param.brandId!}",
		categoryId:"${param.categoryId!}",
		isSp:"${param.isSp!}",
		goodsStatus:"${param.state!}",
		keyword:"${param.keyword!}",
		timeStart:"${param.timeStart!}",
		timeEnd:"${param.timeEnd!}"
	}
	$(function(){
		layui.use(['form', 'layer','laydate'], function(){
		  var layer = layui.layer;
		  var form = layui.form(); 
		
		  var laydate = layui.laydate;
		  var start = {
		    min: '2017-01-01' 
		    ,max: '2099-12-29'
		    ,istoday: false
		    ,choose: function(datas){
		      end.min = datas; //开始日选好后，重置结束日的最小日期
		      end.start = datas //将结束日的初始值设定为开始日
		    }
		  };
		  var end = {
		    min: laydate.now()
		    ,max: '2099-12-29'
		    ,istoday: false
		    ,choose: function(datas){
		      start.max = datas; //结束日选好后，重置开始日的最大日期
		    }
		  };
		  document.getElementById('LAY_demorange_s').onclick = function(){
		    start.elem = this;
		    laydate(start);
		  }
		  document.getElementById('LAY_demorange_e').onclick = function(){
		    end.elem = this
		    laydate(end);
		  }
	});
  
});
</script>
</html>